import AbstractOauthControlPanelApi from '@/api/user/abstractOauthControlPanelApi';
import LoginResponse from '@/structure/loginResponse';
import User from '@/structure/user';

/**
 * 企业微信控制面板
 */
class WxCpControlPanelApi extends AbstractOauthControlPanelApi {
  /**
   * 通过code获取登录信息
   * @param agentId agentId
   * @param code code
   * @return 登录信息
   */
  public loginByCode(agentId: string, code: string): Promise<LoginResponse<User>> {
    return super.get0(`${this.getBase()}/${agentId}/loginByCode`, {
      params: {
        code
      }
    });
  }

  protected getBase(): string {
    return 'user/user/wx/cp/controlPanel';
  }
}

export default new WxCpControlPanelApi();
